package net.xfok.web.client;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class MainActivity extends Activity {
	private static String TAG="MainActivity";
	private static int BUFFER_SIZE=1024;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        InputStream in = getResources().openRawResource(R.raw.book);
        Log.i(TAG,""+inputStream2String(in).length());
        TextView tv=(TextView)findViewById(R.id.text);
        tv.setText(inputStream2String(in));
    }
 
 
    public String inputStream2String(InputStream is){
 	   BufferedReader in = new BufferedReader(new InputStreamReader(is));
 	   StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
 	   try{
 		   String line = "";	   
 		   while ((line = in.readLine()) != null){
 		       buffer.append(line);
 		   }
 	   }catch(Exception e){
 		   e.printStackTrace();
 	   }
 	   return buffer.toString();
 	}
}